<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "category".
 *
 * @property integer $cat_id
 * @property string $name
 * @property integer $parent_id
 * @property integer $level
 * @property integer $sort
 * @property string $extra
 */
class Category extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'category';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['parent_id', 'level', 'sort'], 'integer'],
            [['extra'], 'string'],
            [['name'], 'string', 'max' => 50],
            ['sort','default','value'=>100],
            ['parent_id','default','value'=>0],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'cat_id' => '分类ID',
            'name' => '分类名称',
            'parent_id' => '上级分类ID',
            'level' => '层级',
            'sort' => '排序',
            'extra' => '说明',
        ];
    }
}
